<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('词组访问频率列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <p>词组：</p>
                                <input type="text" name="ci"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="dict:cizuaccess:export">
                    <i class="fa fa-download"></i> 导出
                 </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('dict:cizuaccess:edit')}]];
        var removeFlag = [[${@permission.hasPermi('dict:cizuaccess:remove')}]];
        var prefix = ctx + "dict/cizuaccess";
        var cizuPrefix = ctx + "dict/cizunew";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "词组访问频率",
                columns: [{
                    checkbox: true
                },
                {
                    field : 'ci',
                    title : '词组',
                    visible: true
                },
                {
                    field : 'times',
                    title : '查询次数'
                },
                {
                    field : 'status',
                    title : '是否己收录',
                    formatter: function(value, row, index) {
                		if(value==1){
                		   return '<span class="glyphicon glyphicon-ok"></span>'
                		}else{
                		   return ''
                		}
                	}
                },
                {
                    field : 'kkcStatus',
                    title : '快快查词典',
                    formatter: function(value, row, index) {
                		if(value==1){
                		   return '<span class="glyphicon glyphicon-ok"></span>'
                		}else{
                		   return ''
                		}
                	}
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        if(row.kkcStatus == 1){
                          actions.push(`<a class="btn btn-success btn-xs ${editFlag}" href="javascript:void(0)" onclick="openDetail(\'${row.ci}\', ${row.ciId})"><i class="fa fa-edit"></i>快快查词典</a> `);
                        }
                        if(row.status != 1){
                          actions.push(`<a class="btn btn-info btn-xs ${editFlag}" href="javascript:void(0)" onclick="importToCizu(\'${row.ci}\', ${row.ciId})"><i class="fa fa-edit"></i>入库</a> `);
                        }
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });

        function openDetail(ci, ciId) {
		   var url = `${cizuPrefix}/viewkkc/${ciId}/`
		   $.modal.open(`快快查词典-${ci}`, url, "", "", function(index, layero){
               layer.close(index);
		   });
		}

        function importToCizu(ci, id) {
			$.modal.confirm(`确定入库词语“${ci}”吗?`, function() {
				$.operate.post(prefix + "/importToCizu", { "id": id, "ci": ci });
		    })
		}

    </script>
</body>
</html>